from django.db import models

class Users(models.Model):
    userID = models.CharField(primary_key=True,max_length=64)  #用户ID
    openID=models.CharField(max_length=64) #openID
    password=models.CharField(max_length=64) #密码
    nickName = models.CharField(max_length=16,null=True)
    userGender = models.BinaryField(null=True)#TODO:性别

class Events(models.Model):
    eventName = models.CharField(max_length=32,null=False)
    userID= models.ForeignKey('Users',on_delete=models.CASCADE)
    eventStartDate = models.DateField()   #事件开始日期
    eventEndDate = models.DateField()     #事件结束日期
    eventStartTime=models.TimeField()   #事件开始时间
    eventEndTime=models.TimeField()     #事件结束时间
    eventFinishDate=models.DateField(null=True)  #事件完成日期
    isSubEvent=models.BooleanField()    #是否为子任务
    isRepeat=models.BooleanField()  #是否重复
    eventStatus = models.BooleanField()  #事件完成状态
    eventLevel = models.IntegerField(default=0,null=True) #事件等级
    eventDescription=models.CharField(max_length=200,null=True)    #事件描述

class EventsLaunch(models.Model):
    userID = models.ForeignKey('Users',on_delete=models.CASCADE)
    eventName=models.CharField(max_length=32,null=False)
    sendDate = models.DateField()

class EventsReceive(models.Model):
    eventsLaunchID = models.ForeignKey(EventsLaunch,on_delete=models.CASCADE) #联系发起事件ID
    eventID = models.ForeignKey(Events, on_delete=models.CASCADE)   #联系事件ID
    receiveDate = models.DateField() #接收时间

class EventsRelate(models.Model):
    fatherEventID = models.ForeignKey(Events,on_delete=models.CASCADE,related_name='eventID')    #大事件
    childEventID = models.ForeignKey(Events,on_delete=models.CASCADE,related_name='eventLinkID')#被关联的小事件

class UserSuggestions(models.Model):
    userID = models.ForeignKey('Users',on_delete=models.CASCADE)
    suggestionText = models.TextField(max_length=1024,null=False)
